/******************************

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <iostream>
//for setw, precision()
#include <iomanip>
using namespace std;

class Node{
	char hoten[20];
	int tuoi;

public:
	Node *next;
	Node(){};
	Node(char hoten[], int tuoi){
		strcpy(this->hoten, hoten);
		this->tuoi = tuoi;
	}
	Node(char hoten[]){
		strcpy(this->hoten, hoten);
	};
	int getTuoi(){
		return tuoi;
	}
	void setTuoi(int tuoi){
		this->tuoi = tuoi;
	}
	char* getTen(){
		return hoten;
	}
	void setTen(char *ten){
		strcpy(this->hoten,ten);
	}
	void setInfo(char *ten, int tuoi){
		this->tuoi = tuoi;
		strcpy(this->hoten,ten);

	}

};
class List{
	Node *first;
public:
	void nhap(){
		first = NULL;
		Node *last;
		int i = 0;
		char ten[20];
		cout << "\nNhap cac ptu: ";
		Node *n ;
		while(1){
			//n = (Node*)malloc(sizeof(Node));
			n = new Node;

			cout<<"\nNhap ptu thu "<<++i<<": ";
			cout<<"\nNhap ten: ";
			cin>>ten;
			if (strcmp(ten,"-1") == 0)
			{
				break;
			}

			n->setTen(ten);
			int temp;
			cout<<"\Nhap tuoi: ";
			cin>>temp;
			n->setTuoi(temp);
			n->next = NULL;
			if (first == NULL)
			{

				first = n;
				last = n;
			}
			else{
				last->next = n;
				last = n;
			}

			//free(n);
		}
	}
	void hienthi(){
		Node * p = first;
		cout<<"\nHien thi:";
		while (p != NULL)
		{
			cout<<"\nTen: "<<p->getTen()<<"  Tuoi: "<<p->getTuoi();
			p=p->next;
		}
		//getch();
	}

 int sosanh(char t1[], char t2[]){
		//return (strupr(t1) > strupr(t2)) ? 1: 0;
	 return strcmp(t1,t2);

	}
	
	void sapxep(){
		Node *p =first;
		for (Node * i = first; i->next != NULL; i=i->next)
		{
			for (Node * j = i->next; j != NULL; j=j->next)
			{
				if (sosanh(i->getTen(),j->getTen())<0)
				{
					char t[20]="";
					strcpy(t,i->getTen());
					i->setTen(j->getTen());
					j->setTen(t);
					int a = i->getTuoi();
					i->setTuoi(j->getTuoi());
					j->setTuoi(a);
				}
			}
		}
	}
	Node * findByName(char *hoten){
		Node * p = first;
		while (p != NULL)
		{
			if(strcmp(hoten,p->getTen())==0){
				return p;
			}
			p = p->next;
		}
		return NULL;
	}
	void xoa(char *hoten){
		Node *p = first, *q;
		p = findByName(hoten);
		if(p != NULL){
			while (q->next != p)
			{
				q = q->next;
			}
			q->next = p ->next;
			free(p);
		}
	}
	void xoa(Node *p){
		Node *q;
		if(p != NULL){
			while (q->next != p)
			{
				q = q->next;
			}
			q->next = p ->next;
			free(p);
		}
	}

	void xoaHet(char *hoten){
		Node *p;
		while (true)
		{
			p = findByName(hoten);
			if(p==NULL){break;}
			xoa(p);
		}
	}
};

void main(){
	char s[] = "sss";
	strupr(s);
	char s1[] = "aaa";
	char *s2 = strcpy(s,s1);
	List list;
	list.nhap();
	list.hienthi();
	list.sapxep();
	list.hienthi();
	cout<<"\nNhap ten de xoa: ";
	char ten[20];
	gets(ten);
	list.xoa(ten);
	list.hienthi();
	getch();
}

/**********************************/